import moment from 'moment';
import aepApiRequest from '../utils/aepApiRequest';

export interface IUserMessage {
  alarmMsg?: boolean;  // 告警消息开关
  beginHour?: number; // 免打扰开启时间
  beginMinute?: number;
  endHour?: number; // 免打扰结束时间
  endMinute?: number;
  callNotice?: boolean; // 电话推送开关
  deviceConfigSwitch?: boolean; // 设备配置开关，默认关
  deviceMsg?: boolean; // 设备消息开关
  doDisturb?: boolean; // 免打扰开关
  wxDoNotDisturb?: boolean; // 微信免打扰开关
  wxBeginHour?: number; // 微信免打扰开启时间
  wxBeginMinute?: number;
  wxEndHour?: number; // 微信免打扰结束时间
  wxEndMinute?: number; 
  errorMsg?: boolean; //错误消息开关
  linkMsg?: boolean; //推送链接开关
  smsNotice?: boolean; //短信开关
  wechatNotice?: boolean; //微信消息开关
  zone?: number;
}

export interface ICallPhoneNumber {
  id: number;
  callNumber: string;
}

export async function queryNoticesSetting() {
  return aepApiRequest<IUserMessage>(`app/user/notices/setting`, {
    method: 'GET',
  });
}


export async function updateNoticesSetting(params: IUserMessage) {
  // 补充时区
  params.zone = moment().utcOffset() / 60;
  return aepApiRequest(`app/user/notices/setting`, {
    method: 'PUT',
    body: params,
  });
}

export async function getCallNumberList() {
  return aepApiRequest<ICallPhoneNumber[]>(`app/enterprises/voiceCalling/callNumber/list`, {
    method: 'GET',
  });
}

